<?php
/**
 * Object Relational Persistence Mapping Class for table: test_item
 *
 * @package	com.clearhealth
 * @author	ClearHealth Inc.
 */
class TestItem extends ORDataObject {

	/**#@+
	 * Fields of table: test_item mapped to class members
	 */
	var $ticket_item_id		= '';
	var $test_id		= '';
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'test_item';

	/**
	 * Primary Key
	 */
	var $_key = 'ticket_item_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'TestItem';

	/**
	 * Handle instantiation
	 */
	function TestItem() {
		parent::ORDataObject();
	}		
	
	public function delete($ticketItemId) {
		$testItemService = Celini::newORDO('TestItemAssoService');
		$testItemService->delete($ticketItemId);
		
		$sql = "delete from test_item where ticket_item_id = $ticketItemId";
		$this->_execute($sql);
	}
	
	public function addItem($ticketItemId, $testId, $testItem){
		$data = array (
			'ticket_item_id'	=> $ticketItemId,
			'test_id'		=> $testId);
		$this->populateArray($data);
		$this->persist();

		$testItemService = Celini::newORDO('TestItemAssoService');
		$testItemService->addItem($ticketItemId, $testItem);
	}
	
}
?>
